package f;

import java.io.Closeable;
import java.util.Objects;
import javax.annotation.Nullable;

/* compiled from: Response */
public final class a0 implements Closeable {
    public final y a;
    public final w b;
    public final int c;
    public final String d;
    @Nullable
    public final p e;
    public final q f;
    @Nullable
    public final c0 g;
    @Nullable
    public final a0 h;
    @Nullable
    public final a0 i;
    @Nullable
    public final a0 j;
    public final long k;
    public final long l;
    @Nullable
    public volatile c m;

    /* compiled from: Response */
    public static class a {
        @Nullable
        public y a;
        @Nullable
        public w b;
        public int c;
        public String d;
        @Nullable
        public p e;
        public f.q.a f;
        @Nullable
        public c0 g;
        @Nullable
        public a0 h;
        @Nullable
        public a0 i;
        @Nullable
        public a0 j;
        public long k;
        public long l;

        public a() {
            this.c = -1;
            this.f = new f.q.a();
        }

        public a a(String str, String str2) {
            f.q.a aVar = this.f;
            Objects.requireNonNull(aVar);
            q.a(str);
            q.b(str2, str);
            aVar.a.add(str);
            aVar.a.add(str2.trim());
            return this;
        }

        public a0 b() {
            if (this.a == null) {
                throw new IllegalStateException("request == null");
            } else if (this.b == null) {
                throw new IllegalStateException("protocol == null");
            } else if (this.c < 0) {
                StringBuilder g = c.b.a.a.a.g("code < 0: ");
                g.append(this.c);
                throw new IllegalStateException(g.toString());
            } else if (this.d != null) {
                return new a0(this);
            } else {
                throw new IllegalStateException("message == null");
            }
        }

        public a c(@Nullable a0 a0Var) {
            if (a0Var != null) {
                d("cacheResponse", a0Var);
            }
            this.i = a0Var;
            return this;
        }

        public final void d(String str, a0 a0Var) {
            if (a0Var.g != null) {
                throw new IllegalArgumentException(c.b.a.a.a.D(str, ".body != null"));
            } else if (a0Var.h != null) {
                throw new IllegalArgumentException(c.b.a.a.a.D(str, ".networkResponse != null"));
            } else if (a0Var.i != null) {
                throw new IllegalArgumentException(c.b.a.a.a.D(str, ".cacheResponse != null"));
            } else if (a0Var.j != null) {
                throw new IllegalArgumentException(c.b.a.a.a.D(str, ".priorResponse != null"));
            }
        }

        public a e(q qVar) {
            this.f = qVar.e();
            return this;
        }

        public a(a0 a0Var) {
            this.c = -1;
            this.a = a0Var.a;
            this.b = a0Var.b;
            this.c = a0Var.c;
            this.d = a0Var.d;
            this.e = a0Var.e;
            this.f = a0Var.f.e();
            this.g = a0Var.g;
            this.h = a0Var.h;
            this.i = a0Var.i;
            this.j = a0Var.j;
            this.k = a0Var.k;
            this.l = a0Var.l;
        }
    }

    public a0(a aVar) {
        this.a = aVar.a;
        this.b = aVar.b;
        this.c = aVar.c;
        this.d = aVar.d;
        this.e = aVar.e;
        this.f = new q(aVar.f);
        this.g = aVar.g;
        this.h = aVar.h;
        this.i = aVar.i;
        this.j = aVar.j;
        this.k = aVar.k;
        this.l = aVar.l;
    }

    public void close() {
        c0 c0Var = this.g;
        if (c0Var != null) {
            c0Var.close();
            return;
        }
        throw new IllegalStateException("response is not eligible for a body and must not be closed");
    }

    public c n() {
        c cVar = this.m;
        if (cVar != null) {
            return cVar;
        }
        cVar = c.a(this.f);
        this.m = cVar;
        return cVar;
    }

    public String toString() {
        StringBuilder g = c.b.a.a.a.g("Response{protocol=");
        g.append(this.b);
        g.append(", code=");
        g.append(this.c);
        g.append(", message=");
        g.append(this.d);
        g.append(", url=");
        g.append(this.a.a);
        g.append('}');
        return g.toString();
    }
}
